<?php


abstract class controllerInterface { 
    private $errors = array ();
    private $mess = '';
    
    public $query = '';
    public $error = ''; // временная переменная для последней ошибки, чтоб не использовать геттеры и сеттеры
    
    protected $smarty;
    
    function __get($property){//fb($property);

        if(isset($this->$property))
            return $this->$property;
        else
            return null;
    } // -- __get
    
    function __set($property, $value){
        $this->$property = $value;
    } // -- __set
    
    
      function setParams(array $params){
      // заносит в поля класса соответвующие значения
      // [!] естественно, поля массива должны совпадать с полями класса PhotoModul
          foreach($params as $key => $value)
              $this->$key = $value;
      } // -- setParams()
    
      function getParam($field){       
          return $this->$field;
      }
      
      function setParam($field, $val){       
          $this->$field = $val;
      }
    
    function getErrors() { 
    // get all errors
        return $this->errors; }
    
    function setError (  $error, $type = 'general' ) {
    // Set the error of particular type
        $error['type'] = $type; 
        $error['text'] = $error; 
        $error['html'] = "<span class='msg_err'>$error</span>"; 
        $this->errors[] = $error; 
    }
    
    function addErrors ( array $errors ) {
    // add a set of errors from another object
        $a = array_merge ( $this->errors, $errors );       
        //$a =  $errors + $this->errors ;
        $this->errors = $a;
    }
    
    function printErrors () {  // Error types: general, base, antispam_code, mysql, user, pass, password_confirm, email, screen_name, user_url, picture_url
        $err = '';
        foreach ( $this->errors as $type => $val ) {
            $err .= "<tt class='code'>[$type]:</tt>";
            foreach ( $val as $error ) {
                $err .= $error;
            }
        }
        return $err; 
    }
        
    function setMess ($mess) {  $this->mess .= "<p class='msg'>" . $mess . "</p>"; }
    
    function addMess ($mess) {  $this->mess .=  $mess ; }
    
    function getMess () { return  $this->mess; }
}